package com.sz.exce.service.impl;

import com.sz.exce.dao.SuspectDao;
import com.sz.exce.entity.Suspect;
import com.sz.exce.service.SuspectService;
import com.sz.exce.vo.ExceQueryVo;
import com.sz.exce.vo.PageVO;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SuspectServiceImpl implements SuspectService {
    @Autowired
    SuspectDao suspectDao;
    public int addSuspect(Suspect suspect) {

        return suspectDao.insert(suspect);
    }

    public ExceQueryVo querySuspect(PageVO vo) {

        vo.setStart((vo.getIndex()-1)*vo.getPageSize()+1);
        vo.setEnd(vo.getIndex()*vo.getPageSize());
        ExceQueryVo exceQueryVo = new ExceQueryVo();
        Integer pageCount =(suspectDao.selectCount() +vo.getPageSize()-1)/vo.getPageSize();
        List<Suspect> transfers = suspectDao.selectByPage(vo);
        exceQueryVo.setCount(pageCount);
        exceQueryVo.setList(transfers);
        return exceQueryVo;
    }

    public Suspect querySuspect(String name) {
        return suspectDao.selectByUserName(name);
    }

    public Integer modifySuspectCount(Suspect suspect) {
        return suspectDao.updateByPrimaryKeySelective(suspect);
    }

    public Integer modifyStatus(Suspect suspect) {
        return suspectDao.updateByUserName(suspect);
    }
}
